{extend name="$BASE_POPUP_FORM" /}
{block name="body"}
<link rel="stylesheet" type="text/css" href="__STATIC__/aliyunoss/style.css"/>
<input type="hidden" id="id" name="id" />

<div class="box-content">
    <div class="control-group">
        <label class="control-label">视频别名</label>
        <div class="controls">
            <input type="text" name="alias_name" id="alias_name" class="form-control required" />    
            <span class="tips">识别视频标识</span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">
            分类</label>
        <div class="controls">
            <select name="class_id" id="class_id" class="form-control" style="width:160px">
                <option value="">所有分类</option>
                {volist name="class_id" id="class"}
                <option value="{$class.id}">{$class.video_class_name}</option>
                {/volist}
            </select>
        </div>
    </div>
    
    <div class="control-group">
        <label class="control-label">预览</label>
        <div class="controls">
            <video style="width:300px; display: none" controls preload="auto" src="" id="file_path"></video>
            <div id="container" style="float: left;">
                <a id="selectfiles" href="javascript:void(0);" class='btn'>选择文件</a>
                <a id="postfiles" href="javascript:void(0);" class='btn'>开始上传</a>
            </div>
            <span id="ossfile" class="tips">你的浏览器不支持flash,Silverlight或者HTML5！</span>
        </div>
    </div>
    
    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls">
            <input type="text" name="video_time" id="video_time" class="form-control" readonly="true" />  
            <span class="tips"><button type="button" class="btn btn-primary" id="js_get_time">获取时长</button></span>
        </div>
    </div>
    
</div>
{/block}

{block name="script"}
<script type="text/javascript">
var getInfoUrl = getURL("loadAccess");
</script>
<script type="text/javascript" src="__STATIC__/aliyunoss/lib/plupload-2.1.2/js/plupload.full.min.js"></script>
<script type="text/javascript" src="__STATIC__/aliyunoss/upload.js"></script>
<script type="text/javascript">
var oss_path = "{:config('aliyunoss')['host']}"+'/';

function onLoadDataSuccess(data){
    $("#file_path").show();
    $("#container").hide();
    var video = oss_path + data.file_path;
    $("#id").val(data.id);
    $("#file_path").attr('src', video);
}

$("#js_get_time").click(function(){
    var time = $("#file_path")[0].duration;
    $("#video_time").val(time)
})

function uploadCallback(data){
    data = data.data;
    data.file_path = data.path;
    onLoadDataSuccess(data);
}

</script>
{/block}